package com.androidhive.jsonparsing;

import java.util.ArrayList;

import com.vg.spinner.City;
import com.vg.spinner.ItemStudent_City;
import com.vg.spinner.Student;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

public class MyAdapter_City extends ArrayAdapter<City>{
	private Context mContext;
	private ArrayList<City> arrayList;
	private boolean isCancel;

	public MyAdapter_City(Context context, int textViewResourceId,ArrayList<City> array1, boolean cancel) {
		super(context,textViewResourceId, array1);
		// inital: khoi tao
		this.mContext = context;
		this.arrayList = array1;
		this.isCancel = cancel;
	}
	
	@Override
	public View getDropDownView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		//return super.getDropDownView(position, convertView, parent);
		return getViewdrop(position, convertView, parent);
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		//return super.getView(position, convertView, parent);
		return getViewdrop(position, convertView, parent);
	}
	
public View getViewdrop(int position, View convertView, ViewGroup parent) {
	View view = convertView;
	if(view==null){
		view = new ItemStudent_City(mContext);
	}
	// lay phan tu mang thu position
	final City city = arrayList.get(position);
	if(city!=null){
		TextView name = ((ItemStudent_City)view).name;		
		name.setText(city.getName());
		

	}
	return view;
}
}
